home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Peter Lewis / Morpion 1.0.0 / source / PNL Libraries / MyAssertions.unit < prev    next >
Encoding:
Text File  |  1993-12-01  |  818 b   |  44 lines  |  [TEXT/PJMM]

  1. unit MyAssertions;
  2.  
  3. interface
  4.  
  5.     procedure Assert (b: boolean);
  6.     procedure AssertValidPtr (p: univ ptr);
  7.     procedure AssertValidPtrNil (p: univ ptr);
  8.     procedure AssertValidHandle (h: univ handle);
  9.     procedure AssertValidHandleNil (h: univ handle);
  10.  
  11. implementation
  12.  
  13.     procedure Assert (b: boolean);
  14.     begin
  15.         if not b then begin
  16.             DebugStr('Assert Failed;sc;hc');
  17.         end;
  18.     end;
  19.  
  20.     procedure AssertValidPtr (p: univ ptr);
  21.     begin
  22.         Assert((p <> nil) & (not odd(ord(p))));
  23.     end;
  24.  
  25.     procedure AssertValidPtrNil (p: univ ptr);
  26.     begin
  27.         if p <> nil then
  28.             AssertValidPtr(p);
  29.     end;
  30.  
  31.     procedure AssertValidHandle (h: univ handle);
  32.     begin
  33.         AssertValidPtr(h);
  34.         AssertValidPtr(h^);
  35.         Assert(RecoverHandle(h^) = h);
  36.     end;
  37.  
  38.     procedure AssertValidHandleNil (h: univ handle);
  39.     begin
  40.         if h <> nil then
  41.             AssertValidHandle(h);
  42.     end;
  43.  
  44. end.